<template>
  <div class="container">
    <van-nav-bar title="已完成的订单" left-arrow @click-left="goBack" />
    <div v-for="order in list" :key="order.id">
      <div class="info">
        <div class="time">下单时间：{{ order.createTime }}</div>
        <div class="name">{{ order.station.name }}({{ order.station.concat }})</div>
        <div class="price">¥{{ order.fee }}</div>
        <div class="address">{{ order.station.address }}</div>
      </div>
      <van-card v-for="item in order.list" :key="item.id" :origin-price="item.goods.originPrice" :price="item.goods.price" :desc="item.goods.text" :num="item.count" :title="item.goods.name" :thumb="item.goods.image" @click="showDetail(item.goods)">
      <template #tags>
        <van-tag class="tag" color="#754dec" text-color="#fff">酒水</van-tag>
      </template>
      </van-card>
      <div class="line" />
    </div>
    <div style="height:200px" />
  </div>
</template>

<script>
import _ from 'lodash';
export default {
  data() {
    return {
      list: [],
      defaultStationId: null,
    }
  },
  mounted() {
    const { stationId } = this.$route.query;
    this.defaultStationId = stationId;
    this.getList();
  },
  methods: {
    goBack() {
      this.$router.back();
    },
    async getList() {
      const data = await post('/list/order', { pageNo: 0, pageSize: 100,  search: { state: 'finish' }, sort: { createTime: -1 } });
      if (data.success) {
        this.list = data.result.list;
      }
    },
    showDetail(item) {
      this.$router.push({ path: '/detail', query: { id: item.id } });
    },
  }
}
</script>

<style scoped lang="less">
.container {
  width: 375px;
}
.info {
  background: #d3d3d38b;
  padding: 20px;
}
.row {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
}
.price {
  font-size: 24px;
  color: red;
  margin-bottom: 10px;
}
.time {
  color: grey;
  font-size: 14px;
  margin-bottom: 10px;
}
.name {
  font-size: 16px;
  margin-bottom: 10px;
}
.address {
  color: grey;
  font-size: 12px;
}
.line {
  height: 10px;
  width: 375px;
  background: #d3d3d38b;
  margin: 10px 0;
}
</style>
